﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace ImageTour
{
    class ParallelPairAnnotationTool : ImageAnnotationTool
    {
        int state = 0;
        LineAnnotation l1, l2;

        internal override void DrawOverlay(Graphics g)
        {
            annotations.Draw(view, g);
            annotations.DrawLineHandles(view, g);
            if (l1 != null)
            {
                annotations.DrawHighlightHandle(view, g, l1.Center);
            }
        }

        internal override void MouseDown(int x, int y)
        {
            if (state == 0)
            {
                l1 = annotations.LinesHitTest(view, x, y);
                if (l1 != null)
                    state++;
            }
            else
            {
                l2 = annotations.LinesHitTest(view, x, y);
                if (l2 != null)
                {
                    annotations.ParallelPairs.Add(new Tuple<LineAnnotation, LineAnnotation>(l1, l2));
                    state = 0;
                    l1 = l2 = null;
                }
            }
        }

        internal override void MouseMove(int x, int y)
        {
            
        }

        internal override void MouseUp(int x, int y)
        {
            
        }
    }
}
